/* 
 * File:   LevelEditor.h
 * Copyright (C) 2008, 2009
 *		Sergio Padrino Recio (PadrinatoR)
 *
 * Created on 19 de septiembre de 2008, 18:41
 *
 * This file is part of BombProject.
 * 
 * BombProject is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
   
 * BombProject is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with BombProject.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _LEVELEDITOR_H
#define	_LEVELEDITOR_H

#include <SDL/SDL_framerate.h>
#include "InputHandler.h"
#include "AnimatedSprite.h"
#include <string>

using namespace std;

//TODO: faltan las cintas transportadoras en los sentidos opuestos!
enum LevelTileType {
	TILE_PLAYER_START,
	TILE_ALWAYS_EMPTY,
	TILE_EMPTY_OR_BRICK,
	TILE_BRICK_ITEM,
	TILE_BRICK_NO_ITEM,
	TILE_BELT_L_R, TILE_BELT_U_D, TILE_BELT_U_L, TILE_BELT_U_R, TILE_BELT_D_L, TILE_BELT_D_R,
	TILE_INDESTRUCTIBLE_BLOCK,
	TILE_ARROW_UP, TILE_ARROW_DOWN, TILE_ARROW_LEFT, TILE_ARROW_RIGHT,
	TILE_SEESAW,
	TILE_TUNNEL,
	TILE_BOUNCING_STATUE,
	TILE_TRAPDOOR,
	TILE_HOLE,
	TILE_RANDOM_ITEM,
	TILE_SEESAW_LEFT,
	TILE_SEESAW_RIGHT,
	TILE_TUNNEL_AUX11, TILE_TUNNEL_AUX12, TILE_TUNNEL_AUX13,
	TILE_TUNNEL_AUX21, TILE_TUNNEL_AUX22, TILE_TUNNEL_AUX23,
	TILE_TUNNEL_AUX31,					  TILE_TUNNEL_AUX33
};

#define NUM_TILES 22
	
class LevelEditor {
protected:
	//ButtonState *mControlUp, *mControlDown, *mControlLeft, *mControlRight, *mControlEnter, *mControlEscape;
	SDL_Surface* mScreenSurface;
	FPSmanager mFramerateManager;
	LevelTileType mLevelTiles[17][11];
	AnimatedSprite* mLevelSurfaces[17][11];
	
	string mLevelsPath, mSkinsPath, mSkinName, mMapName;
	SDL_Surface* mBackground;
	
	string mTileNameList[NUM_TILES], mTileSeqList[NUM_TILES];
	int mGameOffsetX, mGameOffsetY;
	int mGameWidth, mGameHeight;
	int mTileWidth, mTileHeight;
	
	bool mMapModified;
	
public:
	LevelEditor();
	~LevelEditor();
	
	void run();

protected:
	void init();
	
	bool selectLevel();
	bool tileEditor();
	
	void putItem(int tile_x, int tile_y, LevelTileType tile_type);
	void removeItem(int tile_x, int tile_y);
	
	void destroy();
	
	void saveLevel();
	void loadLevel(string map_name);
	
	bool mouseInRectangle(int mx, int my, int x1, int y1, int x2, int y2);
	string InputString(string prompt);
};

#endif	/* _LEVELEDITOR_H */

